home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / c / AmiVoGL_MDEV.lha / src / buffer.c < prev    next >
C/C++ Source or Header  |  1994-04-12  |  2KB  |  133 lines

  1. #include "vogl.h"
  2.  
  3. /*
  4.  * backbuffer
  5.  *
  6.  *    swap drawing to backbuffer - returns -1 if no
  7.  * backbuffer is available.
  8.  */
  9. void backbuffer(int yes)
  10. {
  11. Token    *tok;
  12.  
  13. if (!vdevice.initialised)
  14. verror("backbuffer: vogl not initialised");
  15.  
  16. if (vdevice.inobject) {
  17.     tok = newtokens(2);
  18.     tok[0].i = BACKBUFFER;
  19.     tok[1].i = yes;
  20.     return;
  21.     }
  22.  
  23. if (vdevice.attr->a.mode == SINGLEBUF)
  24. return;
  25.  
  26. if (yes) {
  27.     if ((*(vdevice.dev.Vbackb))() < 0)
  28.     verror("device doesn't support double buffering\n");
  29.  
  30.     vdevice.inbackbuffer = 1;
  31.     }
  32. else
  33. vdevice.inbackbuffer = 0;
  34.  
  35. }
  36.  
  37. /* ------------------------------------------------------------------------ */
  38.  
  39. /*
  40.  * frontbuffer
  41.  *
  42.  *    start drawing in the front buffer again. This
  43.  * will always work!
  44.  */
  45. void frontbuffer(int yes)
  46. {
  47. Token    *tok;
  48.  
  49. if (!vdevice.initialised)
  50. verror("frontbuffer: vogl not initialised");
  51.  
  52. if (vdevice.inobject) {
  53.     tok = newtokens(2);
  54.     tok[0].i = FRONTBUFFER;
  55.     tok[1].i = yes;
  56.     return;
  57.     }
  58.  
  59. if (vdevice.attr->a.mode == SINGLEBUF)
  60. return;
  61.  
  62. (*(vdevice.dev.Vfrontb))();
  63.  
  64. vdevice.inbackbuffer = 0;
  65. }
  66.  
  67. /* ------------------------------------------------------------------------ */
  68.  
  69. /*
  70.  * swapbuffers
  71.  *
  72.  *    swap the back and front buffers - returns -1 if
  73.  * no backbuffer is available.
  74.  */
  75. void swapbuffers(void)
  76. {
  77. Token    *tok;
  78.  
  79. if (vdevice.inobject) {
  80.     tok = newtokens(1);
  81.     tok[0].i = SWAPBUFFERS;
  82.     return;
  83.     }
  84.  
  85. if (!vdevice.initialised)
  86. verror("swapbuffers: vogl not initialised");
  87.  
  88. if (vdevice.inbackbuffer != 1)
  89. verror("swapbuffers: double buffering not initialised.\n");
  90.  
  91. if ((*(vdevice.dev.Vswapb))() < 0)
  92. verror("device doesn't support double buffering\n");
  93. }
  94.  
  95. /* ------------------------------------------------------------------------ */
  96.  
  97. /*
  98.  * doublebuffer()
  99.  *
  100.  *    Flags our intention to do double buffering....
  101.  *    tries to set it up etc etc...
  102.  */
  103. void doublebuffer(void)
  104. {
  105. if (!vdevice.initialised)
  106. verror("doublebuffer: vogl not initialised");
  107.  
  108. if ((*vdevice.dev.Vbackb)() < 0)
  109. verror("device doesn't support double buffering\n");
  110.  
  111. vdevice.inbackbuffer = 1;
  112. }
  113.  
  114. /* ------------------------------------------------------------------------ */
  115.  
  116. /*
  117.  * singlebuffer()
  118.  *
  119.  *    Goes back to singlebuffer mode....(crock)
  120.  */
  121. void singlebuffer(void)
  122. {
  123. if (vdevice.attr->a.mode == SINGLEBUF)
  124. return;
  125.  
  126. (*vdevice.dev.Vfrontb)();
  127.  
  128. vdevice.inbackbuffer = 0;
  129. }
  130.  
  131. /* ------------------------------------------------------------------------ */
  132.  
  133.